//
//  BHSportInGoingCell.swift
//  BigHealth
//
//  Created by 蔺百好 on 2021/7/15.
//

import UIKit

class BHSportInGoingCell: UITableViewCell {
    
    
    @IBOutlet weak var targetName_label: UILabel!
    
    @IBOutlet weak var des_label: UILabel!
    
    @IBOutlet weak var haveAMarkBtn: UIButton!
    
    @IBOutlet weak var progress_label: UILabel!
    
    @IBOutlet weak var state_all_lengh_view: UIView!
    
    @IBOutlet weak var state_progress_view: UIView!
    
    // 总长度120，计算比例
    @IBOutlet weak var progress_width: NSLayoutConstraint!
    
    var model: BHSportTargetModel! {
        didSet {
            self.targetName_label.text = model.target
            self.des_label.text = model.plan
            self.progress_label.text = "当日进度\(model.progress)%"
            if model.clockStatus == 0 {
                self.haveAMarkBtn.setTitle("打卡", for: .normal)
                self.haveAMarkBtn.backgroundColor = .color_34CE98
                self.haveAMarkBtn.addLayerCorner(16, 0.5, .color_34CE98)
                self.haveAMarkBtn.setTitleColor(.white, for: .normal)
            }else if model.clockStatus == 1 {
                self.haveAMarkBtn.setTitle("已打卡", for: .normal)
                self.haveAMarkBtn.backgroundColor = .color_E0F5ED
                self.haveAMarkBtn.addLayerCorner(16, 0.5, .color_34CE98)
                self.haveAMarkBtn.setTitleColor(.color_34CE98, for: .normal)

            }else if model.clockStatus == 2 {
                self.haveAMarkBtn.setTitle("缺卡", for: .normal)
                self.haveAMarkBtn.backgroundColor = .color_FFF6E6
                self.haveAMarkBtn.setTitleColor(.color_ffba25, for: .normal)
            }
            
            self.progress_width.constant = model.progressWidth
        }
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
 
        self.state_all_lengh_view.addLayerCorner(4, 0, .white)
        self.state_progress_view.addLayerCorner(4, 0, .white)
        self.haveAMarkBtn.addLayerCorner(16, 0, .white)

    }

    func toDone()  {
        self.haveAMarkBtn.addLayerCorner(16, 0.5, .color_34CE98)
        self.haveAMarkBtn.backgroundColor = .color_E0F5ED
    }
    
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

      
    }
    
}
